package com.fancy.learncenter.ui.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.fancy.learncenter.R;
import com.fancy.learncenter.bean.CartoonClassItemBean;
import com.fancy.learncenter.ui.adapter.base.CommonRecycleViewAdapter;
import com.fancy.learncenter.ui.adapter.base.CustomViewHold;
import com.fancy.learncenter.ui.callback.AlbumImpl;

import java.util.List;

/**
 * Created by shiweiwei on 2018/1/5.
 */

public class CartoonClassListAdapter extends CommonRecycleViewAdapter<CartoonClassItemBean>{

    private AlbumImpl listener;

    public void setListener(AlbumImpl listener) {
        this.listener = listener;
    }

    public CartoonClassListAdapter(Context mContext, List<CartoonClassItemBean> itemDatas) {
        super(mContext, R.layout.cartoon_list_item_layout, itemDatas);
    }

    @Override
    public void bindView(CustomViewHold customViewHold, CartoonClassItemBean item, final int position) {

        TextView class_name = customViewHold.getView(R.id.unit_name);
        if (!TextUtils.isEmpty(item.getClassName())) {
            class_name.setText(item.getClassName());
        }

        customViewHold.getRoorView().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (listener != null){
                    listener.onClick(position);
                }
            }
        });

    }
}
